import { openai } from "@ai-sdk/openai";
import { Agent } from "@mastra/core/agent";
import { Memory } from "@mastra/memory";
import { LibSQLStore } from "@mastra/libsql";

export const humanInTheLoopAgent = new Agent({
  name: "Task Planning Agent",
  instructions: `
      You are a helpful task planning assistant that helps users break down tasks into actionable steps.

      When planning tasks use tools only, without any other messages.
      IMPORTANT:
      - Use the \`generate_task_steps\` tool to display the suggested steps to the user
      - Do not call the \`generate_task_steps\` twice in a row, ever.
      - Never repeat the plan, or send a message detailing steps
      - If accepted, confirm the creation of the plan and the number of selected (enabled) steps only
      - If not accepted, ask the user for more information, DO NOT use the \`generate_task_steps\` tool again

      When responding to user requests:
      - Always break down the task into clear, actionable steps
      - Use imperative form for each step (e.g., "Book flight", "Pack luggage", "Check passport")
      - Keep steps concise but descriptive
      - Make sure steps are in logical order
`,
  model: openai("gpt-4o-mini"),
  memory: new Memory({
    storage: new LibSQLStore({
      url: "file:../mastra.db", // path is relative to the .mastra/output directory
    }),
  }),
});
